<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../static/webix/webix.css" type="text/css"
	charset="utf-8">
<script src="../static/webix/webix.js" type="text/javascript"
	charset="utf-8"></script>
</head>
<body>


	<script type="text/javascript" charset="utf-8">
		webix.ui({
			view : "window",
			height : 250,
			width : 300,
			left : 50,
			top : 50,
			move : true,
			head : "This window can be moved",
			id:"my_win",
			body : {
				template : "Some text"
			}
		}).hide();

		webix.ui({
			width : 500,
			rows : [ {
				view : "toolbar",
				elements : [ {
					view : "button",
					value : "添加",
					width : 100,
					click : "add_row"
				}, {
					view : "button",
					value : "删除",
					click : "delete_row",
					width : 100
				}

				]
			}, //1st row
			{
				cols : [ {
					view : "form",
					id : "myform",
					elements : [ {
						view : "text",
						name : "title",
						placeholder : "Title"
					}, {
						view : "text",
						name : "year",
						placeholder : "Year"
					} ]
				},//1st column
				{
					view : "list",
					id : "mylist",
					template : "#title# - #year#", // which data to show
					select : true, //enables selection 
					height : 400,
					url : "/film/getList"
				} ]
			} ]
		});

		function delete_row() {
			var id = $$("mylist").getSelectedId();
			if (id == "") {
				webix.message("请选择列表项目");
				return;
			}
			/* 	webix.confirm({
					title : "删除",
					ok : "是",
					cancel : "否",
					type : "confirm-error",
					text : "确认删除数据吗？",
					callback:function(result){ webix.alert({title:"Your Choice", text:"Result" +result });
				});
			 */
			webix.confirm({
				title : "删除",
				ok : "是",
				cancel : "否",
				type : "confirm-error",
				text : "确认删除数据吗？",
				callback : function(result) {
					if (result) {
						webix.ajax().post("/film/delete/" + id);
						$$("mylist").remove(id);
					} else
						return;
				}
			});

			/* webix.ajax().post("/film/delete/" + id, function(result) {
				webix.message(result); //show server side response
			});
			webix.message("你选择的栏目ID是111:" + id); */

		}

		function add_row() {
			$$("my_win").show();
		}
	</script>
</body>
</html>